import api from '../../api'
export default {
    namespaced: true, // 具名模块 this.$store.dispatch('home/SET_SHOP_LIST')
    // namespaced: false, // 具名模块 this.$store.dispatch('SET_SHOP_LIST')
    state: {
        shopList: [],
        total: 0
    },
    mutations: {
        setShopList(state, data) {
            state.shopList = state.shopList.concat(data);
        },
        setTotal(state, data) {
            state.total = data
        }
    },
    actions: {
        async SET_SHOP_LIST(context, data = { pageIndex: 1, pageSize: 10 }) {
            const res = await api.getShopList(data)
            if (res.success) {
                context.commit('setShopList', res.data.list)
                context.commit('setTotal', res.data.total)
            } else {
                alert('失败了')
            }
        }
    }
}